<%@ Page language="c#" Inherits="Dimok.Aspx.Manager.Underwriting.BuyersOrder" CodeFile="BuyersOrder.aspx.cs" %>
<%@ Register TagPrefix="Car" TagName="Info" Src="/Manager/Lib/Controls/CarInfo.ascx" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > 
<HTML>
<HEAD>
<TITLE>Decision</TITLE>
<META name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<META name="CODE_LANGUAGE" Content="C#">
<META name=vs_defaultClientScript content="JavaScript">
<META name=vs_targetSchema content="http://schemas.microsoft.com/intellisense/ie5">
<?XML:NAMESPACE PREFIX="COOL"/>
<LINK rel="stylesheet" type="text/css" href="/CSS/Outlook.css">
<STYLE>
cool\:tip{behavior: url(/Include/HTC/cooltip_js.htc)}
INPUT{overflow-x:visible;width:100%}
LEGEND {BEHAVIOR: url(/Include/HTC/Toggle.htc);COLOR:navy;FONT-WEIGHT:bold}
TD{white-space:nowrap }
.bigList{behavior:URL(/include/htc/BigList.htc)}
.RO{FONT-WEIGHT: bold}
.Numeric{TEXT-ALIGN: right}
.neg{color:darkred}
.bar{color:navy}
INPUT.neg{border:1 solid black}
</STYLE>
<SCRIPT language="javascript" src="/include/common.js"></SCRIPT>
<SCRIPT language="javascript" src="/include/RDS.js"></SCRIPT>
<SCRIPT language="javascript" src="/include/SOAP.js"></SCRIPT>
<SCRIPT language="javascript" src="/include/XML.js"></SCRIPT>
<SCRIPT language="javascript" src="/include/Events.js"></SCRIPT>
<SCRIPT language="javascript" src="../Common/Common.js"></SCRIPT>
<SCRIPT language="javascript" src="../Common/Events.js"></SCRIPT>
</HEAD>
<BODY onload="page_Load()">
<COOL:TIP id="oTip" avoidmouse="true" DURATION="60"></COOL:TIP>
<XML id="xmlLoanInfo" Runat="server"></XML>
<XML id="xmlLoanInfoTIL" Runat="server"></XML>
<TABLE id="tblLoanInfo" cellpadding="0" cellspacing="0" border="0" width="1%" style="BORDER-COLLAPSE: collapse">
	<COL width="1%"><COL width="1%" align="right"><COL width="100%">
	<TR><TD colspan="100"><CAR:INFO runat="server" /></TD>
	<TR><TD  style="PADDING:2px 0PX">Miles/Year
			<TD align="right"><SPAN class="RO" dataSrc="#xmlLoanInfoTIL" datafld="MilesPerYear" preset="currency" noDollar></SPAN>
			<TD></TD>
<TR><TD colspan="100"><TABLE width="100%"><TR><TD width="50%"><HR><TH nowrap class="bar">Terms<TD width="50%"><HR></TABLE>
	<TR><TD>Advance
			<TD><SPAN dataSrc="#xmlLoanInfoTIL" datafld="AdvancePercent_Gross"  class="RO"></SPAN>
			<TD>%<B style="COLOR: firebrick">[<INPUT dataSrc="#xmlLoanInfoTIL" datafld="AdvancePercentCalc" FieldName="AdvancePercentOverride" size="3" class="Numeric" style="width:2em" style="COLOR: firebrick" numeric>]</B>
					<IMG dataSrc="#xmlLoanInfoTIL" datafld="AdvancePercentOverrideFlag" src="/images/blank16x16.gif" title="History" class="TipMe" onclick="history(this,'AdvancePercentOverride')" width="16" height="16">

	<TR><TD>AddOn Rate
			<TD><SPAN dataSrc="#xmlLoanInfoTIL" datafld="AddOnRateMax"  class="RO"></SPAN>
			<TD>%<SELECT dataSrc="#xmlLoanInfoTIL" datafld="AddOnRateOverride" style="COLOR: red" numeric><OPTION></OPTION><OPTION value='11.00'>11.00</OPTION><OPTION value='11.50'>11.50</OPTION><OPTION value='12.00'>12.00</OPTION><OPTION value='12.50'>12.50</OPTION><OPTION value='13.00'>13.00</OPTION><OPTION value='13.50'>13.50</OPTION><OPTION value='14.00'>14.00</OPTION><OPTION value='14.50'>14.50</OPTION><OPTION value='15.00'>15.00</OPTION><OPTION value='15.50'>15.50</OPTION><OPTION value='16.00'>16.00</OPTION><OPTION value='16.50'>16.50</OPTION><OPTION value='17.00'>17.00</OPTION></SELECT>
					<IMG dataSrc="#xmlLoanInfoTIL" datafld="AddOnRateOverrideFlag" src="/images/blank16x16.gif" title="History" class="TipMe" onclick="history(this,'AddOnRateOverride')" width="16" height="16">
	<TR><TD>Term
			<TD align="right"><INPUT dataSrc="#xmlLoanInfo" datafld="LoanTerm" size="3" class="Numeric" style="width:auto">
			<TD>Mos
	<TR><TD>Contract Date
			<TD><INPUT dataSrc="#xmlLoanInfo" datafld="ContractDate_F" size="10" style="width:auto" null>
			<TD>
	<TR><TD>Fst Pmt Date
			<TD><INPUT dataSrc="#xmlLoanInfoTIL" datafld="FirstPaymentDate_F" size="10" style="width:auto" id="txtFPD"></TD>
			<TD>&nbsp;<INPUT value="+15" onclick="var txt=getParentTR(this).all['txtFPD'];txt.value=dateAdd('dd',15,txt.value);UF(txt)" type="button" style="width:3ex">
					&nbsp;<INPUT value=" -15" onclick="var txt=getParentTR(this).all['txtFPD'];txt.value=dateAdd('dd',-15,txt.value);UF(txt)" type="button" style="width:3ex">
			</TD>			
<TR><TD colspan="100"><TABLE width="100%"><TR><TH width="50%"><HR><TH nowrap class="bar">Amounts</TH><TH width="50%"><HR></TABLE>
	<TR><TD>Sales Price<TD nowrap><INPUT dataSrc="#xmlLoanInfo" datafld="Price" class="Numeric" size="10" value="00000.00"><TD></TD>
	<TR><TD>Dealer Fee<TD nowrap><INPUT dataSrc="#xmlLoanInfo" datafld="DealerFee" class="Numeric" size="10" numeric><TD></TD>
	<TR><TD>Taxable Fees<TD nowrap><INPUT dataSrc="#xmlLoanInfoTIL" datafld="TaxableFees" class="Numeric" size="10" numeric><TD></TD>
	<TR><TD>Trade In<TD nowrap><INPUT dataSrc="#xmlLoanInfo" datafld="TradeIn" class="Numeric" size="10" numeric><TD></TD>
	<!--TR><TD  style="PADDING:2px 0PX">Tag<TD align="right"><SPAN class="RO" dataSrc="#xmlLoanInfo" datafld="TagFee" preset="currency" showZeros></SPAN><TD></TD-->
	<TR><TH align="right">Total:
			<TD align="right" class="RO"><SPAN dataSrc="#xmlLoanInfoTIL" datafld="PriceTaxable"  preset="currency" showZeros></SPAN>
	<TR><TH align="right">Sales Tax:
			<TD align="right" class="RO"><SPAN dataSrc="#xmlLoanInfoTIL" datafld="SalesTaxAmount"  preset="currency" showZeros></SPAN>
	<TR><TD>NonTaxable Fees
			<TD nowrap><INPUT dataSrc="#xmlLoanInfo" datafld="NonTaxableFees" class="Numeric" size="10" numeric>
			<TD></TD>
	<TR><TD>Down Payment
			<TD nowrap><INPUT dataSrc="#xmlLoanInfo" datafld="DownPayment" class="Numeric" size="10" numeric>
			<TD></TD>
	<TR><TD>Payment
			<TD><INPUT dataSrc="#xmlLoanInfoTIL" datafld="Payment" FieldName="PaymentOverride" class="Numeric" size="10" numeric>
			<TD><IMG dataSrc="#xmlLoanInfoTIL" datafld="PaymentOverrideFlag" src="/images/blank16x16.gif" title="History" class="TipMe" onclick="history(this,'PaymentOverride')" width="16" height="16"></TD>
			
	<TR><TD><B>Hide This:</B>
			<TD align="right" class="RO"><SPAN dataSrc="#xmlLoanInfoTIL" datafld="Profit"  preset="currency" showZeros></SPAN>
</TABLE>
<FIELDSET style="width:1%" id="tblDisb" style="display:block">
	<LEGEND state="+"><LABEL>Disbursement (To dealer:<SPAN dataSrc="#xmlLoanInfoTIL" datafld="AdvanceAmount_Net" preset="currency"></SPAN>)</LABEL></LEGEND>
	<TABLE style="display:none">
		<COL align="right">
		<TR><TD nowrap><B>Amount Financed</B><TD class="RO" align="right"><SPAN dataSrc="#xmlLoanInfoTIL" datafld="AmountFinanced" preset="currency">000000.00</SPAN>
		<TR><TD nowrap><B>Gross Advance</B><TD class="RO" align="right"><SPAN dataSrc="#xmlLoanInfoTIL" datafld="AdvanceAmount_Gross" preset="currency"></SPAN>
		<TR><TD>Doc Stamps
				<TD align="right" class="neg"><SPAN dataSrc="#xmlLoanInfoTIL" datafld="DocStamps" preset="currency" showZeros class="neg"></SPAN>
		<TR><TD>Trackers Fee
				<TD align="right" class="neg"><SPAN dataSrc="#xmlLoanInfoTIL" datafld="TrackersFee" preset="currency" showZeros class="neg"></SPAN>
		<TR><TD>Processing Fee
				<TD align="right" class="neg"><SPAN dataSrc="#xmlLoanInfoTIL" datafld="ProcessingFee" preset="currency" showZeros class="neg"></SPAN>
		<TR><TD>PPP
				<TD align="right" class="neg"><SPAN dataSrc="#xmlLoanInfoTIL" datafld="PPP"  preset="currency" showZeros class="neg"></SPAN>
		<TR><TD>Discount
				<TD align="right" class="neg"><SPAN dataSrc="#xmlLoanInfoTIL" datafld="DiscountAmount_UpFront"  preset="currency" showZeros class="neg"></SPAN>
		<TR><TH><DIV style="FONT-SIZE: 1pt; WIDTH: 100%; BORDER-BOTTOM: black thin groove"></DIV></TH>
		<TR><TD nowrap class="RO">Total To Dealer<TD class="RO" align="right"><SPAN dataSrc="#xmlLoanInfoTIL" datafld="AdvanceAmount_Net" preset="currency" class="Numeric"></SPAN>
	</TABLE>
</FIELDSET>
<FIELDSET style="width:1%" id="tblOwned">
	<LEGEND state="+"><LABEL>Owned To Dealer: (<SPAN dataSrc="#xmlLoanInfoTIL" datafld="OwnedToDealer" preset="currency"></SPAN>)</LABEL></LEGEND>
	<TABLE style="display:none"><COL align="right"><COL align="right">
		<TR><TD>Trackers
				<TD align="right" class="neg"><SPAN dataSrc="#xmlLoanInfoTIL" datafld="TrackersWithhold" preset="currency" showZeros class="neg"></SPAN>
		<TR><TD>Discount<TD nowrap><SPAN dataSrc="#xmlLoanInfoTIL" datafld="DiscountAmount_BackEnd" preset="currency" showZeros class="neg"></SPAN>
	</TABLE>
</FIELDSET>
<BR>
<FIELDSET style="width:1%" id="tblTIL">
	<LEGEND state="+"><LABEL>Truth-In-Lending (Payment:<SPAN dataSrc="#xmlLoanInfoTIL" datafld="Payment" class="RO" preset="currency"></SPAN>)</LABEL></LEGEND>
	<DIV style="display:none">
<TABLE border="0">
	<TR><TD nowrap>APR<TD class="RO" align="right"><SPAN dataSrc="#xmlLoanInfoTIL" datafld="APR" showZeros></SPAN><TD>%</TD>
	<TR><TD nowrap>AddOn<TD class="RO" align="right"><SPAN dataSrc="#xmlLoanInfoTIL" datafld="AddOnRateByPayment" showZeros></SPAN><TD>%</TD>
	<TR><TD nowrap>Finance Charge<TD class="RO" align="right"><SPAN dataSrc="#xmlLoanInfoTIL" datafld="FinanceCharge" preset="currency" showZeros>00000.00</SPAN>
	<TR><TD nowrap>Amount Financed<TD class="RO" align="right"><SPAN dataSrc="#xmlLoanInfoTIL" datafld="AmountFinanced" preset="currency" showZeros></SPAN>
	<TR><TD nowrap>Total Of Payments<TD class="RO" align="right"><SPAN dataSrc="#xmlLoanInfoTIL" datafld="TotalPayments" preset="currency" showZeros></SPAN>
	<TR><TD nowrap>Total Sales Price<TD class="RO" align="right"><SPAN dataSrc="#xmlLoanInfoTIL" datafld="TotalSalesPrice" preset="currency" showZeros></SPAN>
</TABLE>
<TABLE datasrc="#XmlPayments" cellpadding="0" cellspacing="0" style="BORDER-COLLAPSE: collapse" border="1" style="BEHAVIOR: url(/Include/HTC/rowover_js.htc)" selectable="1">
	<THEAD valign="top"><TH>Pmt</TH><TH>Mos</TH><TH>Interest</TH><TH>Principle</TH><TH>Balance</TH><TH>Finance Charge</TH></THEAD>
	<TR align="right">
		<TD><SPAN datafld="PaymentNumber"></SPAN></TD>
		<TD><SPAN datafld="Mos"></SPAN></TD>
		<TD><SPAN datafld="ToInterest"></SPAN></TD>
		<TD><SPAN datafld="ToPrinciple"></SPAN></TD>
		<TD><SPAN datafld="RemainingPrinciple"></SPAN></TD>
		<TD><SPAN datafld="FinanceCharge"></SPAN></TD>
	</TR>
</TABLE>
	</DIV>
</FIELDSET>
<DIV id="divRegHist" style="display:none">
<TABLE datasrc="#xmlReqHist" style="FONT: statusbar; BORDER-COLLAPSE: collapse" border="1" bordercolor="black" onreadystatechange="if(document.body.funcResize)document.body.funcResize()">
	<THEAD><TR><TH>Value</TH><TH>When</TH><TH>Who</TH></TR></THEAD>
	<TR>
		<TD nowrap><SPAN datafld="Value"></SPAN></TD>
		<TD nowrap><SPAN datafld="When"></SPAN></TD>
		<TD nowrap><SPAN datafld="Who"></SPAN></TD>
	</TR>
</TABLE>
<XML id="xmlReqHist">[xml]</XML>
</DIV>
<TABLE>
	<TR><TD><LABEL for="chkDeclined">Declined</LABEL>
			<TD colspan="100" align="left"><INPUT id="chkDeclined" dataSrc="#xmlLoanInfo" datafld="Declined" type="checkbox" style="border:none;width:1.5em">
</TABLE>
<XML id="xmlPayments" runat="server"></XML>
</BODY>
</HTML>
<SCRIPT language="javascript">
var applID = getParam("ApplID");
initWS("DECISION","Decision.asmx?WSDL&ApplID="+applID);
function page_Load(){
	attachToDealerChanged(reloadMe,applID);
	attachToVerTreeChanged(reloadConditions,applID);
	attachToKeyDown();
	initPreset();
	initInputs();
	UF_AddCallBack(reloadTIL);
	UF_AddCallBack(function(){fireDecisionInfoChanged(applID);})

}
function doBookValueChange(){
	var ret = WS(CO("xmlLoanInfoTIL"),"","");
	if( showSOAPError(ret) )return false;
	reloadTIL(ret);
}
function pullCredit(){
	var ret = WS(CO("PullCredit"));
	if( showSOAPError(ret) )return false;
	fireCreditRepulled(applID);
}
function faxCallback(){
	showModalDialog("CallBack.aspx?ApplID="+ApplID()+"&IsFax=1&NoLock=1",{opener:top});
}
function changeSalesTax(){
	var tax = prompt("Sales Tax:",xmlLoanInfo.recordset("SalesTaxPercent"));
	if( !tax )return;
	UF(null,"SalesTaxPercent",tax,"xmlLoanInfo");
}
function reloadTIL(ret,el,fieldName,fieldValue,wsMethod){
	if( wsMethod && !wsMethod.match(/loaninfo/i) )return;
	//if( thread !== true )return setTimeout(function(){return reloadTIL(ret,true)},500);
	if( !xmlLoanInfoTIL.loadXML(ret.value) )alert("Error while loading TIL");
	setTimeout("initPreset(document.body);try{activeElement.select()}catch(e){}",500);
	reloadPayments();
}
function reloadPayments(){
	var ret = WS(cb,"PaymentsSchedule");
	// Local
	function cb(ret){
		if( showSOAPError(ret) )return false;
		xmlPayments.loadXML(ret.value);
		xmlPayments.state = xmlPayments.state;
	}
}
function reloadMe(eventObject){
	location.reload();
}
// ******** Conditions **********
function addCondition(el){
	if( !checkWS(true) )return setTimeout(function(){return addCondition(el);},500);
	var condID = el.Value || 0;
	var condLable = el.Text;
	if( !condLable )return;
	var ret = WS(CO("AddCondition"),condID,condLable);
	if( showSOAPError(ret) )return false;
	el.Text = "";
	updateConditions(ret.value);
	fireEvents(_eventObject(condID));
}
function deleteCondition(el){
	if( !checkWS(true) )return setTimeout(function(){return deleteCondition(el);},500);
	var condID = rsField(el,"ID").Value;
	var ret = WS(CO("DeleteCondition"),condID);
	if( showSOAPError(ret) )return false;
	updateConditions(ret.value);
	fireEvents(_eventObject(condID));
}
function updateCustomCondition(el){
	if( !checkWS(true) )return setTimeout(function(){return deleteCondition(el);},500);
	var condID = rsField(el,"ID").Value;
	var ret = WS(CO("UpdateCustomCondition"),condID,el.value);
	if( showSOAPError(ret) )return false;
	fireEvents(_eventObject(-1));
}
function updateConditions(xmls){
	xmlConditions.loadXML(xmls[0]);
	txtAddCondition.fillSelect(xmls[1]);
}
function reloadConditions(){
	var ret = WS(CO("ConditionsAll"));
	if( showSOAPError(ret) )return false;
	updateConditions(ret.value);
}
// ********* History *********
function historyAdvance(el){
	var ret = WS(CO("GetColumnHistory"),null,null,null,null,'AdvancePercentOverride');
	if( showSOAPError(ret) )return false;
	el.coolTip = divRegHist.innerHTML.replace("[xml]",ret.value);
	el.fireEvent("onmouseover",event);
}
function history(el,fielName){
	var ret = WS(CO("GetColumnHistory"),null,null,null,null,fielName);
	if( showSOAPError(ret) )return false;
	el.coolTip = divRegHist.innerHTML.replace("[xml]",ret.value);
	el.fireEvent("onmouseover",event);
}
function fireEvents(eventObject){
	fireOnReloadVerTree(eventObject);
	fireDecisionInfoChanged(eventObject);
}
function _eventObject(verID){return {applID:applID,reload:parseInt(verID)<=0}}
</SCRIPT>
